package com.hyh.prize.controller;


import com.hyh.prize.entity.TabGgcardObtain;
import com.hyh.prize.entity.TabSaleplanGiftcode;
import com.hyh.prize.service.ObtainService;
import com.lww.springcloudapi.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/cash/")
@Api(tags = "兑奖模块")
public class CashController {
    @Resource
    private ObtainService obtainService;

    @PostMapping("prize")
    @ApiOperation("兑奖，传入用户信息和刮刮卡信息")
    public Result cashPrize(TabGgcardObtain tabGgcardObtain){

        //兑奖
        boolean receive = obtainService.receive(tabGgcardObtain);
        if(receive){
            return Result.ok();
        }
        return Result.fail();
    }

    @PostMapping("info")
    @ApiOperation("查询用户列表")
    public Result info(String uid){
        List<TabGgcardObtain> list = obtainService.getList(uid);
        return Result.ok(list);
    }

    @PostMapping("getLpList")
    @ApiOperation("获取中奖商品列表")
    public Result getLpList(String level){
        List<TabSaleplanGiftcode> gift = obtainService.getGift(level);
        return Result.ok(gift);
    }

    @PostMapping("ixtis")
    @ApiOperation("获取查询刮刮卡是否中奖")
    public Result  ixtis(String ggkId){
        String ixtis = obtainService.ixtis(ggkId);
        return Result.ok(ixtis);
    }
}
